package com.techstar.ats.codec.live.decoder;

import io.netty.buffer.ByteBuf;
import com.techstar.ats.codec.MessageDecoder;
import com.techstar.ats.dxp.live.F04DeviceStatusBitmapType;
import com.techstar.ats.dxp.live.rep.F04DeviceStatusBitmap;

public enum F04DeviceStatusBitmapDecoder implements MessageDecoder<F04DeviceStatusBitmap> {
	INSTANCE;

	public F04DeviceStatusBitmap create() {
		return new F04DeviceStatusBitmap();
	}

	public void decode(ByteBuf buf, F04DeviceStatusBitmap value) {
		value.line = buf.readUnsignedShort();
		value.rtu = buf.readUnsignedShort();
		int cnt = buf.readUnsignedShort();

		for(int i = 0; i < cnt; ++i) {
			F04DeviceStatusBitmapType type = F04DeviceStatusBitmapTypeDecoder.INSTANCE.create();
			F04DeviceStatusBitmapTypeDecoder.INSTANCE.decode(buf, type);
			value.types.add(type);
		}

	}
}
